USE [TrioJFLApp]
GO

/****** Object:  StoredProcedure [dbo].[SP_Upload_SAPMaterialToMonitor_GC_ProdHierarchy]    Script Date: 09/26/2018 15:41:39 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE   PROCEDURE [dbo].[SP_Upload_SAPMaterialToMonitor_GC_ProdHierarchy] 
  @MaterialNumber NVARCHAR(20),
  @CreateUser NVARCHAR(20),
  @CN_Description NVARCHAR(40),
  @ProdHierarchy NVARCHAR(20)
  
AS 
BEGIN

SET @MaterialNumber=upper(RTRIM(@MaterialNumber))
 
	BEGIN
		UPDATE sim SET 
	    sim.ProductHierarchy=CASE @ProdHierarchy WHEN '' THEN sim.ProductHierarchy ELSE @ProdHierarchy END,
	    sim.CN_Description=CASE @CN_Description WHEN '' THEN sim.CN_Description ELSE @CN_Description END,
	    sim.GC_P_User=@CreateUser,
	    sim.GC_P_Date=case  when GC_P_Date IS NULL then  getdate() else GC_P_Date end ,
	    sim.LastUploadTime=GETDATE()
	    FROM SAP_ItemMaster sim WHERE sim.Material_Number=@MaterialNumber
	END
  
END
GO


